/**
 * Created by wlc on 2018/4/1.
 */

/**
 * 判断数据是否为空
 * @param v
 * @returns {boolean}
 */
function isEmpty(v) {
    switch (typeof v) {
        case 'undefined':
            return true;
        case 'string':
            if (v.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
            break;
        case 'boolean':
            if (!v) return true;
            break;
        case 'number':
            if (0 === v || isNaN(v)) return true;
            break;
        case 'object':
            if (null === v || v.length === 0) return true;
            for (var i in v) {
                return false;
            }
            return true;
    }
    return false;
}

/**
 * 去掉字符串前后的空格
 * @param param
 * @returns {*|string}
 */
function trim(param) {
    if ((vRet = param) === '') { return vRet; }
    while (true) {
        if (vRet.indexOf (' ') === 0) {
            vRet = vRet.substring(1, parseInt(vRet.length));
        } else if ((parseInt(vRet.length) !== 0) && (vRet.lastIndexOf (' ') === parseInt(vRet.length) - 1)) {
            vRet = vRet.substring(0, parseInt(vRet.length) - 1);
        } else {
            return vRet;
        }
    }
}

/**
 * 数据权限判断
 * @param authorityVar
 * @returns {string}
 */
function dataAuthority_break(authorityVar) {
    switch (authorityVar){
        case "F":return "rwmd";
        case "E":return "rwm-";
        case "D":return "rw-d";
        case "C":return "rw--";
        case "B":return "r-md";
        case "A":return "r-m-";
        case "9":return "r--d";
        case "8":return "r---";
        case "7":return "-wmd";
        case "6":return "-wm-";
        case "5":return "-w-d";
        case "4":return "-w--";
        case "3":return "--md";
        case "2":return "--m-";
        case "1":return "---d";
        case "0":return "----";
    }
}